//
//  SLStatusPictureCell.swift
//  Sina15
//
//  Created by 盼 on 16/4/15.
//  Copyright © 2016年 pan. All rights reserved.
//

import UIKit
import SnapKit
import SDWebImage

class SLStatusPictureCell: UICollectionViewCell {
    
    var statusPicture: SLStatusPicture? {
        didSet {
            
            let pic_url = NSURL(string: statusPicture?.thumbnail_pic ?? "")
            print(pic_url)
            pictureView.sd_setImageWithURL(pic_url)
        }
    }
    
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
   func setupUI(){
    
    contentView.addSubview(pictureView)
    
    //设置约束
    pictureView.snp_makeConstraints { (make) -> Void in
        
        //设置图片框上下左右的约束和contentView的上下左右对齐
        make.edges.equalTo(contentView.snp_edges)
    }
    
    }
    
    //图片框
    private lazy var pictureView: UIImageView = {       
        let picView = UIImageView()
        
        //设置图片的填充模式
        picView.contentMode = .ScaleAspectFill

        //手写代码需要手动设置裁剪设置裁剪
        picView.clipsToBounds = true
        
        return picView
    }()
}
